package com.xxxx.server.controller;

import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.service.impl.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @description: 文件
 * @author: Honors
 * @create: 2021-11-10
 */
@RestController
@RequestMapping("/file")
@Api(value = "文件上传", tags = "文件上传")
public class FileUploadController {

    @Resource
    private FileUploadService fileUploadService;

    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public RespBean fileUpload(@RequestBody MultipartFile file) throws IOException {
        return fileUploadService.uploadFile(file);
    }

    @ApiOperation("导出学生成绩")
    @PostMapping("/export")
    public RespBean export(
            @RequestParam Integer itmId) throws IOException {
        return fileUploadService.export(itmId);
    }


}
